package com.weixing.mall.provider.support.mq;

import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.provider.service.IActivityGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.stereotype.Component;

/**
 * @author small
 *
 */
@Slf4j
@Component
public class DivideStockRedisMessage implements MessageListener {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private IActivityGoodsService activityGoodsService;

    @Override
    public void onMessage(Message message, byte[] pattern) {
        RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
        String msg = serializer.deserialize(message.getBody());
//        log.info("接收到的消息是：{}", msg);
//        String[] split = msg.split(GlobalConstant.symbol.MH);
//        long actId = Long.parseLong(split[0]);
//        long itemId = Long.parseLong(split[1]);
//        activityGoodsService.offLoading(actId, itemId);
    }
}
